using System.Web.UI;
using System.Web.UI.HtmlControls;

namespace FluentTags
{

    public class ULTag : Tag<ULTag>
    {
        public ULTag() : base("ul"){}
        
        
        public ULTag(Control control) : this()
        {
            Controls.Add(control);
        }
        
        
        
        
        public LITag<ULTag> LI()
        {
            var ctrl = new LITag<ULTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ULTag LI(LITag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public LITag<ULTag> LI(string text)
        {
            var ctrl = new LITag<ULTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public LITag<ULTag> LI(Control control)
        {
            var ctrl = new LITag<ULTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public LITag<ULTag> LI(object value)
        {
            return LI(SafeString(value));
        }
        
        
    }

    public class ULTag<ParentType> : ChildTag<ULTag<ParentType>, ParentType>
        where ParentType : HtmlGenericControl
    {
        public ULTag(ParentType parent) : base("ul", parent) { }

        
        
        
        public LITag<ULTag<ParentType>> LI()
        {
            var ctrl = new LITag<ULTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ULTag<ParentType> LI(LITag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public LITag<ULTag<ParentType>> LI(string text)
        {
            var ctrl = new LITag<ULTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public LITag<ULTag<ParentType>> LI(Control control)
        {
            var ctrl = new LITag<ULTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public LITag<ULTag<ParentType>> LI(object value)
        {
            var ctrl = new LITag<ULTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        
        
    }
}